<template>
  <div>
     <van-nav-bar
      :title="$route.meta.title"
      left-arrow
      @click-left="$router.back()"
    />
    <img :src="$HOST+goodsinfo.img">
    <H3>{{ goodsinfo.goodsname }}</H3>
     <van-button type="danger"  @click="addCar({id:goodsinfo.id,num:1})"  >加入购物车</van-button>
  </div>
</template>

<script>
import { getGoodInfo } from "@/common/request"
import {  mapActions } from "vuex"
export default {
    data(){
        return{
          goodsinfo:{}
        }
    },
    created(){
       this.getInfo();
    },
    methods:{
       ...mapActions({
        addCar:'cart/add_car'
      }),
      async getInfo(){
          this.goodsinfo = await getGoodInfo(this.$route.params.id);
      }
    },
    components:{}
}

</script>
<style scoped>
</style>